﻿using System;
using TiaoTiaoCode.Common.Extensions;

namespace TiaoTiaoCode.Common.Dtos
{
    /// <summary>
    /// 枚举类对象
    /// </summary>
    public class EnumObjectDto
    {
        /// <summary>
        /// Id
        /// </summary>
        public int Id { get; internal set; }

        /// <summary>
        /// 枚举值
        /// </summary>
        public string Name { get; internal set; }

        /// <summary>
        /// 枚举描述
        /// </summary>
        public string Description { get; internal set; }

        public EnumObjectDto(Enum um)
        {
            this.Id = (int)Convert.ChangeType(um, typeof(int));
            this.Name = um.ToString();
            this.Description = um.GetDescription();
        }

        public EnumObjectDto(int id, string name)
        {
            this.Id = id;
            this.Name = this.Description = name;
        }

        public EnumObjectDto(int id, string name, string description)
        {
            this.Id = id;
            this.Name = name;
            this.Description = description;
        }
    }
}
